/*
 * addon.h
 *
 *  Created on: 2010-1-7
 *      Author: gavinkwoe
 */

#ifndef ADDON_SREGEX_H_
#define ADDON_SREGEX_H_

#include "addon_features.h"
#include "addon_std.h"
#include "addon_objbase.h"

/*************************************************************************
* MACRO
*************************************************************************/

#define REGCOND_INFINITE		(0xFFFFFFFF)

/*************************************************************************
* PROTOTYPE
*************************************************************************/

struct __struct_addon_regcond;
typedef struct __struct_addon_regcond		addon_regcond_t;
typedef struct __struct_addon_regcond *		addon_regcond_ptr_t;

struct __struct_addon_regmatch;
typedef struct __struct_addon_regmatch		addon_regmatch_t;
typedef struct __struct_addon_regmatch *	addon_regmatch_ptr_t;

/*************************************************************************
* STRUCTURE
*************************************************************************/

struct __struct_addon_regcond
{
	unsigned short *	char_set;
	unsigned long		char_cnt;
	unsigned long		min_match;
	unsigned long		max_match;
};

struct __struct_addon_regmatch
{
	unsigned long		offset_beg;
	unsigned long		offset_end;
};

/*************************************************************************
* INTERFACE
*************************************************************************/

ADDON_INTERFACE_( IAddonSRegex, 1, IObject )
{
	__INHERIT_FROM( IObject )

	ADDON_METHOD( SetPattern )	( ADDON_REF(IObject) thiz, IN addon_regcond_ptr_t pcond, IN unsigned long ncond );
	ADDON_METHOD( Match )		( ADDON_REF(IObject) thiz, IN unsigned short * str, IN unsigned long len,
															IN unsigned long nmatch, OUT addon_regmatch_ptr_t pmatch );
};

/*************************************************************************
* DECLARATION
*************************************************************************/

#if defined(__cplusplus)
extern "C" {
#endif	// #if defined(__cplusplus)

ADDON_IMPORT ADDON_REF(IObject)	addon_create_sregex( void * reserved );

#if defined(__cplusplus)
}
#endif	// #if defined(__cplusplus)

/*************************************************************************
* MACRO
*************************************************************************/

#define IAddonSRegex_VTBL( p )				ADDON_GET_VTBL_(p, IAddonSRegex)
#define IAddonSRegex_CALL( p, a )			IAddonSRegex_VTBL(p)->a
#define IAddonSRegex_SetPattern( p, a, b )	IAddonSRegex_CALL( p, SetPattern )( p, a, b )
#define IAddonSRegex_Match( p, a, b, c, d )	IAddonSRegex_CALL( p, Match )( p, a, b, c, d )

#endif /* ADDON_SREGEX_H_ */
